var t = getApp();

Page({
  data: {
    show: !1,
    hiddenmodalput: !1,
    hiddenmodalput1: !1,
    name: "",
    input: "",
    Forname: [],
    Background: ["#91b5ff", "#8894ea", "#7ccafe", "#65e4d3", "#79e5c9", "#ff9a64", "#fea692"],
    Background1: ["#939afe", "#7489dc", "#6bb0ff", "#45ced8", "#6cdfb5", "#ff9574", "#fb8188"],
    _num: 0,
    Wshow: !1,
    cdDisReason: "",
    nmDisReason: "",
    // 人数
    arr: []

  },
  onLoad: function(options) {
    var that = this
    var zid = options.zid
    var openid = wx.getStorageSync('openid')
    t.util.request({
      'url': 'entry/wxapp/Docuser.orderguanfenzu',
      data: {
        zid: zid,
        openid: openid
      },
      success: function(res) {
        console.log(res)
        that.setData({
          UnbankedRegister: res.data.data
        })
      }
    })
    t.util.request({
      'url': 'entry/wxapp/Docuser.orderguanzhu',
      data: {
        zid: zid
      },
      success: function(res) {
        console.log(res)
        that.setData({
          signCount: (res.data.count.length),
          userlist: res.data.data
        })
      }
    })
    t.util.request({
      'url': 'entry/wxapp/Docuser.addfenzu',
      data: {
        zid: zid,
        op: 'display'
      },
      success: function(res) {
        console.log(res)
        that.setData({
          arr: res.data
        })
      }
    })
    that.setData({
      zid: zid
    })
  },
  menuClick: function(t) {
    console.log(t.target.dataset), this.setData({
      _num: t.target.dataset.num,
      nmDisReason: t.target.dataset.text,
      cdDisReason: t.target.dataset.uuid
    });
  },
  Wconfirm: function(e) {
    var that = this
    var q_id = e.currentTarget.dataset.q_id
    var jiechuinput = that.data.jiechuinput
    t.util.request({
      'url': 'entry/wxapp/Docuser.addfenzu',
      data: {
        jieyutext: jiechuinput,
        q_id: q_id,
        op: 'jieyue'
      },
      success: function(res) {
        wx.showToast({
          title: "已解约成功",
          icon: "none",
          duration: 1e3,
          success: function() {
            that.setData({
              Wshow: !1
            })
            var zid = that.data.zid
            t.util.request({
              'url': 'entry/wxapp/Docuser.orderguanfenzu',
              data: {
                zid: zid
              },
              success: function(res) {
                console.log(res)
                that.setData({
                  UnbankedRegister: res.data.data
                })
              }
            })
          }
        });
      }
    })
    console.log(q_id)
  },
  Wcall: function(t) {
    this.setData({
      Wshow: !1
    });
  },
  shu: function(e) {
    var huzopenid = e.currentTarget.dataset.huzopenid
    var change = e.currentTarget.dataset.change
    console.log(change)
    if (change == 1) {
      wx.navigateTo({
        url: '/hyb_yl/mysubpages/pages/xinzengyiliao/xinzengyiliao?huzopenid=' + huzopenid + '&fuwu_name=' + '患者病程'
      });
    } else {
      wx.showToast({
        title: '患者未开启档案授权',
        icon: 'none',
        duration: 1e3
      })
    }

  },
  input: function(t) {
    console.log(t.detail.value), this.setData({
      input: t.detail.value
    });
  },
  jiechuinput: function(t) {
    console.log(t.detail.value), this.setData({
      jiechuinput: t.detail.value
    });
  },
  grabble: function(e) {
    var that = this;
    var kewords = that.data.input
    var zid = that.data.zid
    if (kewords == '') {
      wx.showToast({
        title: "请输入患者昵称或者姓名全称",
        icon: "none",
        duration: 1e3
      })
    } else {
      //查询用户昵称或者姓名
      t.util.request({
        'url': 'entry/wxapp/Docuser.allfenzuuser',
        data: {
          zid: zid,
          kewords: kewords,
          op: 'sousuo'
        },
        success: function(res) {
          console.log(res)
          var sousuinfo = JSON.stringify(res.data)
          wx.navigateTo({
            url: "/hyb_yl/backstageFollowUp/pages/casControlSeet/casControlSeet?sousuinfo=" + sousuinfo,
            success: function(t) {}
          })
        }
      })
    }
  },
  Wmodalinput: function() {
    this.setData({
      hiddenmodalput: !0
    });
  },
  Winput: function(t) {
    console.log(t.detail.value), this.setData({
      name: t.detail.value
    });
  },
  Winputa: function(t) {
    console.log(t.detail.value), this.setData({
      namea: t.detail.value
    });
  },
  cancel: function() {
    this.setData({
      hiddenmodalput: !1
    });
  },
  confirm: function() {
    var that = this;
    var zid = that.data.zid
    if (wx.showLoading({
        title: "加载中",
        mask: !0
      }), "" == that.data.name) wx.showToast({
      title: "请设置分组名",
      icon: "none",
      duration: 2e3
    });
    else {
      var fenzname = that.data.name
      t.util.request({
        'url': 'entry/wxapp/Docuser.addfenzu',
        data: {
          zid: zid,
          fenzname: fenzname,
          op: 'post'
        },
        success: function(res) {
          console.log(res)
          wx.hideLoading();
        }
      })
    }
  },
  cancela: function() {
    this.setData({
      hiddenmodalput1: !1
    });
  },
  confirma: function(e) {
    var that = this
    console.log(e)
    var zid = that.data.zid
    var fenzuid = e.currentTarget.dataset.fenzuid
    var fenzname = that.data.namea
    t.util.request({
      'url': 'entry/wxapp/Docuser.addfenzu',
      data: {
        zid: zid,
        fenzname: fenzname,
        fenzuid: fenzuid,
        op: 'update'
      },
      success: function(res) {
        console.log(res)

      }
    })
  },
  onShow: function(a) {
    var that = this
    let pages = getCurrentPages();
    let currPage = pages[pages.length - 1];
    var zid = that.data.zid
    t.util.request({
      'url': 'entry/wxapp/Docuser.orderguanzhu',
      data: {
        zid: zid
      },
      success: function(res) {
        console.log(res)
        that.setData({
          signCount: (res.data.count.length),
          userlist: res.data.data
        })
      }
    })
    if (currPage.data.type == 1) {
      var that = this
      var zid = that.data.zid
      t.util.request({
        'url': 'entry/wxapp/Docuser.Orderguanfenzu',
        data: {
          zid: zid
        },
        success: function(res) {
          console.log(res)
          that.setData({
            UnbankedRegister: res.data.data
          })
        }
      })
    }
    t.util.request({
      'url': 'entry/wxapp/Docuser.addfenzu',
      data: {
        zid: zid,
        op: 'display'
      },
      success: function(res) {
        console.log(res)
        that.setData({
          arr: res.data
        })
      }
    })
  },
  Wmovement: function(e) {
    var that = this
    var u_id = e.currentTarget.dataset.u_id
    var zid = that.data.zid
    var q_id = e.currentTarget.dataset.q_id
    var beizhu = e.currentTarget.dataset.beizhu
    wx.showActionSheet({
      itemList: ["移动", "解除签约", "修改备注"],
      success: function(n) {
        console.log(n)
        if (n.tapIndex == 0) {
          wx.navigateTo({
            url: "/hyb_yl/backstageFollowUp/pages/casControlmovement/casControlmovement?u_id=" + u_id + '&zid=' + zid + '&q_id=' + q_id
          })
        }
        if (n.tapIndex == 1) {
          that.setData({
            Wshow: !0,
            q_id: q_id
          })
        }
        if (n.tapIndex == 2) {
          wx.navigateTo({
            url: "/hyb_yl/backstageServicess/pages/casControlname/casControlname?q_id=" + q_id + '&beizhu=' + beizhu + '&u_id=' + u_id
          })
        }
      }
    });
  },
  onClock: function(a) {

  },
  onClock2: function(a) {
    var e = wx.getStorageSync("log") || "",
      o = this;
    wx.request({
      url: t.globalData.dic + "doctor/sign/listInform/" + e + "/0",
      data: {},
      success: function(t) {
        console.log(t.data.data.list);
        for (var a = 0; a < t.data.data.list.length; a++)
          if (0 == t.data.data.list[a].signState) return void o.setData({
            show: !0
          });
      }
    });
  },
  bindTouchStart: function(t) {
    this.startTime = t.timeStamp;
  },
  bindTouchEnd: function(t) {
    this.endTime = t.timeStamp;
  },
  ClickGrouping: function(t) {
    console.log(t)
    var fenzuid = t.currentTarget.dataset.fenzuid
    var zid = this.data.zid
    wx.navigateTo({
      url: "/hyb_yl/backstageFollowUp/pages/casControlNav/casControlNav?fenzuid=" + fenzuid + '&zid=' + zid
    });
  },
  longTap: function(a) {
    var e = this;
    var fenzuid = a.currentTarget.dataset.fenzuid
    var fenzname = a.currentTarget.dataset.name
    e.setData({
      creatername: a.currentTarget.dataset.name,
      fenzuid: a.currentTarget.dataset.fenzuid
    })
    wx.showActionSheet({
      itemList: ["解散分组", "分组重命名"],
      success: function(o) {
        var n = wx.getStorageSync("log") || "",
          s = a.currentTarget.dataset.groupid;
        e.setData({
          groupid: a.currentTarget.dataset.groupid,
          creater: a.currentTarget.dataset.creater
        }), 0 == o.tapIndex ? wx.request({
          url: t.globalData.dic + "doctor/manage/group/delete/" + n + "/" + s,
          success: function(t) {
            console.log(t), e.onClock(), e.onClock2();
          }
        }) : 1 == o.tapIndex && e.setData({
          hiddenmodalput1: !0
        });
      }
    });
  }
});